<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/res/js/activity/activityBase.js"></script>
</head>
<body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
			<form id="query-form" class="search_form clearfix">
				<dl>
					<dt>名称：</dt>
					<dd>
						<input type="text" name="name" />
					</dd>
				</dl>
				<dl>
	                <dt>是否推荐：</dt>
	                <dd>
	                	<select name="isRecommend" id="isRecommend" class="txt grid-8">
	                		<option value="">--请选择--</option>
	                		<option value="1">是</option>
	                		<option value="2">否</option>
	                	</select>
	                </dd>
	            </dl>
				<p class="search_form_btn">
					<input type="button" value="搜索" class="icon_serach"
						onclick="admin.activityBase.query()" />
				</p>
			</form>
		</div>
		<div data-options="region:'center',border:false">
			<table id="datagrid"
				data-options="url:'${pageContext.request.contextPath}/activity/base/list',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'type',width:60,align:'center',formatter:formatType ">类型</th>
						<th data-options="field:'sponsorName',width:150,align:'center'">主办方</th>
						<th data-options="field:'logo',width:180,align:'center',formatter:formatImg">logo图片</th>
						<th data-options="field:'name',width:80,align:'center' ">名称</th>
						<th data-options="field:'status',width:60,align:'center',formatter:formatStatus ">状态</th>
						<th data-options="field:'signCount',width:100,align:'center' ">报名人数</th>
						<th data-options="field:'isShow',width:60,align:'center',formatter:formatIsShow ">是否显示</th>
						<th data-options="field:'isRecommend',width:60,align:'center',formatter:formatRecommendStatus">是否推荐</th>
						<th data-options="field:'recommendOidx',width:60,align:'center',formatter:formatRecommendOidx">推荐位</th>
						<th data-options="field:'strNewAt',width:150,align:'center' ">创建时间</th>
						<th data-options="field:'id',align:'center',width:120,formatter:formatOperation">管理操作</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<script>
		function formatOperation(value, row, index) {
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			var l_html = '';
			if (row.isShow == "1") {
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.activityBase.unclaimed('
						+ row.id + ')">屏蔽</a>';
			} else if (row.isShow == "2") {
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.activityBase.receive('
						+ row.id + ')">恢复</a>';
			}
			if(isRecommend=="1"){//已推荐
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.activityBase.unRecommend('+row.id+')">取消推荐</a>';
			}else if(isRecommend=="2"){//未推荐且审批通过的圈子才能推荐
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.activityBase.recommend('+row.id+')">推荐</a>';
			}
			return l_html;
		}

		function formatType(type) {
			var l_html = '';//类型:1-社区;2-圈子
			if (type == 1) {
				l_html = "社区";
			} else if (type == 2) {
				l_html = "圈子";
			}
			return l_html;
		}
		function formatStatus(status) {
			var l_html = '';//状态activityStatusEnum:1-准备报名;2-报名中;3-进行中;4-已结束;5-已失效
			if (status == 1) {
				l_html = "准备报名";
			} else if (status == 2) {
				l_html = "报名中";
			} else if (status == 3) {
				l_html = "进行中";
			} else if (status == 4) {
				l_html = "已结束";
			} else if (status == 5) {
				l_html = "已失效";
			}
			return l_html;
		}

		function formatIsShow(isShow) {
			var l_html = '';//是否显示:1-是;2-否',
			if (isShow == 1) {
				l_html = "是";
			} else if (isShow == 2) {
				l_html = "否";
			}
			return l_html;
		}

		function formatRecommendOidx(value, row, index) {
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			if (isRecommend == "1") {
				return row.recommendOidx;
			} else {
				return "";
			}
		}
		function formatRecommendStatus(value, row, index) {
			var isRecommend = row.isRecommend;//是否推荐:1-是 2-否
			if (isRecommend == "1") {
				return '【已推荐】';
			}
		}
		function formatImg(resumeImg) {
			if (null == resumeImg || '' == resumeImg) {
				return "";
			}
			var imgs = resumeImg.split(";")
			return '<img style="width:120px;height:120px;" src="http://file.xfquanquan.com'+imgs[0]+'"/>';
		}
	</script>
</body>
</html>
